import UrlRequest from './service/request';
import { isResponseSuccess } from '@/utils/bizUtils';

const sysbackRequest = new UrlRequest(isResponseSuccess);

const requestToData = async (options, startLoading, stopLoading) => {
  const res = await sysbackRequest.request(options, startLoading, stopLoading);
  return res?.retData;
}

const requestToStatus = async (options, startLoading, stopLoading) => {
  const res = await sysbackRequest.request(options, startLoading, stopLoading);
  return res?.retStatus;
}

const requestToExport = (options, startLoading, stopLoading) => {
  return sysbackRequest.request({ ...options, isExport: true }, startLoading, stopLoading);
}

const commonRequest = (options) => {
  return sysbackRequest.request(options);
}

export {
  requestToData,
  requestToStatus,
  requestToExport,
  commonRequest
}
